#include <stdio.h>

int RetFind(int arr[3][10], int *py, int *px, int f) {
    int x = *px - 1;
    int y = 0;
    for (; arr[y][x] < f && y < *py; y++); //从右上角开始沿纵向查找
    for (; arr[y][x] > f && x >= 0; x--); //随后向左横向查找
    if (arr[y][x] == f) {
        *px = x;
        *py = y;
        return 1;
    } else {
        return 0;
    }
}

int main() {
    int x = 10;
    int y = 3;
    int f = 0;
    int arr[3][10] = {{0,  1,  2,  3,  4,  5,  6,  7,  8,  9},
                      {10, 11, 12, 13, 14, 15, 16, 17, 18, 19},
                      {20, 21, 22, 23, 24, 25, 26, 27, 28, 29}};
    printf("请出入要查找的数:>");
    scanf("%d", &f);
    int ret = RetFind(arr, &y, &x, f);
    if (ret == 1) {
        printf("第%d行 第%d列\n", y, x);
    } else {
        printf("没找到!");
    }
    return 0;
}